package us.icitap.timsportal.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity implementation class for Entity: Officer
 *
 */
@Entity
@Table(name="OFFICER", schema="TIMSPORTAL")
@SequenceGenerator(name = "officer_seq", sequenceName = "TIMSPORTAL.SQ_TIMSPORTAL_OFFICER", allocationSize = 1)
public class Officer implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -491512238268706969L;
	@Id
	@Column(length=10)
	@GeneratedValue(generator="officer_seq")
	private Integer id;
	@Column(name="OFFICER_ID",length=7)
	private String officerId;
	private String forename;
	private String surname;
	@Column(name="FATHER_NAME")
	private String fatherName;
	private String function;
	private String rank;
	@Column(name="DATE_OF_BIRTH")
	@Temporal( TemporalType.DATE)
	private Date dob;
	@JoinColumn(name="ORG_STRUCTURE_ID")
	@ManyToOne(fetch=FetchType.EAGER)
	private OrgStructure orgStructure;
	private boolean status;
	@Column(name="RECORD_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	private Date recordDate;
	@Column(name="RECORD_USER", length=40)
	private String recordUser;
	@Column(name="LAST_UPDATE_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastUpdateDate;	

	@Column(name="PARENT_STRUCTURE_IDS")
	private String parentStructureIds;

	@Column(name="STRUCTURE_ID")
	private Integer structureId;
	
	@Column(name="STRUCTURE_NAME", length=255)
	private String structureName;

	public Officer() {
		super();
	}   
	public String getOfficerId() {
		return this.officerId;
	}

	public void setOfficerId(String officerId) {
		this.officerId = officerId;
	}   
	public String getForename() {
		return this.forename;
	}

	public void setForename(String forename) {
		this.forename = forename;
	}   
	public String getSurname() {
		return this.surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}   
	public String getFatherName() {
		return this.fatherName;
	}

	public void setFatherName(String fatherName) {
		this.fatherName = fatherName;
	}   
	public String getFunction() {
		return this.function;
	}

	public void setFunction(String function) {
		this.function = function;
	}   
	public String getRank() {
		return this.rank;
	}

	public void setRank(String rank) {
		this.rank = rank;
	}   

	public Date getDob() {
		return dob;
	}
	public void setDob(Date dob) {
		this.dob = dob;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public OrgStructure getOrgStructure() {
		return orgStructure;
	}
	public void setOrgStructure(OrgStructure orgStructure) {
		this.orgStructure = orgStructure;
	}
	
	public String[] getParentStructureIds() {
		return parentStructureIds.split(",");
	}
	public void setParentStructureIds(String parentStructureIds) {
		this.parentStructureIds = parentStructureIds;
	}

	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	public Date getRecordDate() {
		return recordDate;
	}
	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}
	public String getRecordUser() {
		return recordUser;
	}
	public void setRecordUser(String recordUser) {
		this.recordUser = recordUser;
	}
	public Date getLastUpdateDate() {
		return lastUpdateDate;
	}
	public void setLastUpdateDate(Date lastUpdateDate) {
		this.lastUpdateDate = lastUpdateDate;
	}
	public Integer getStructureId() {
		return structureId;
	}
	public void setStructureId(Integer structureId) {
		this.structureId = structureId;
	}
	public String getStructureName() {
		return structureName;
	}
	public void setStructureName(String structureName) {
		this.structureName = structureName;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((forename == null) ? 0 : forename.hashCode());
		result = prime * result
				+ ((function == null) ? 0 : function.hashCode());
		result = prime * result
				+ ((officerId == null) ? 0 : officerId.hashCode());
		result = prime
				* result
				+ ((parentStructureIds == null) ? 0 : parentStructureIds
						.hashCode());
		result = prime * result + ((rank == null) ? 0 : rank.hashCode());
		result = prime * result
				+ ((structureId == null) ? 0 : structureId.hashCode());
		result = prime * result
				+ ((structureName == null) ? 0 : structureName.hashCode());
		result = prime * result + ((surname == null) ? 0 : surname.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Officer))
			return false;
		Officer other = (Officer) obj;
		if (forename == null) {
			if (other.forename != null)
				return false;
		} else if (!forename.equals(other.forename))
			return false;
		if (function == null) {
			if (other.function != null)
				return false;
		} else if (!function.equals(other.function))
			return false;
		if (officerId == null) {
			if (other.officerId != null)
				return false;
		} else if (!officerId.equals(other.officerId))
			return false;
		if (parentStructureIds == null) {
			if (other.parentStructureIds != null)
				return false;
		} else if (!parentStructureIds.equals(other.parentStructureIds))
			return false;
		if (rank == null) {
			if (other.rank != null)
				return false;
		} else if (!rank.equals(other.rank))
			return false;
		if (structureId == null) {
			if (other.structureId != null)
				return false;
		} else if (!structureId.equals(other.structureId))
			return false;
		if (structureName == null) {
			if (other.structureName != null)
				return false;
		} else if (!structureName.equals(other.structureName))
			return false;
		if (surname == null) {
			if (other.surname != null)
				return false;
		} else if (!surname.equals(other.surname))
			return false;
		return true;
	}


   
}
